#include "Log.hpp"
#include "Reactor.hpp"
#include "Listener.hpp"

using namespace LogModule;
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cout << "Usage: " << argv[0] << " port" << std::endl;
        exit(1);
    }
    Reactor reactor;
    uint16_t port = std::stoi(argv[1]);
    auto con = std::make_shared<Listener>(port);

    // Listener listener(port);
    // 把listenfd封装为一个connection
    // auto con=std::make_shared<Connection>(listener.Fd());
    // func_t f=std::bind(&Listener::Accepter,&listener,con);
    // con->InitCB(f,nullptr,nullptr);
    // listen->InitCB([&listener](){listener.Accepter();},nullptr,nullptr);
    // listen->SetEvents(EPOLLIN|EPOLLET);
    // auto con=Factory::BulidConnection(listener.Fd(),EPOLLIN|EPOLLET,[&listener](){listener.Accepter();},nullptr,nullptr);
    reactor.InsertConnection(con);
    reactor.Loop();
}